type Buffer = ref object
  seqs:seq[seq[int]]

var b=Buffer(seqs: @[
  @[10, 20, 30],
  @[40, 50, 60],
  @[70, 80, 90]
])

proc `[]`(b: Buffer, index:int):int =
  var i = index div 3
  var j = index mod 3
  return b.seqs[i][j]

proc `[]=`(b: var Buffer, index:int, v:int) =
  var i = index div 3
  var j = index mod 3
  b.seqs[i][j]=v

echo b[4]
b[4]=b[4]*100
echo b[4]
